using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DTO;
using BUS;
using Utility;
using SlimeeLibrary;

public partial class Admin_nhanvienthem : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Loaddata();
        if(Session["UserName"] == "")
        {
            Response.Redirect("dangnhap.aspx");
        }
    }

    private void Loaddata()
    {
        ddr_chucvu.DataSource = tbchucvuBUS.GETAll();
        ddr_chucvu.DataTextField = tbchucvuDTOColumn.Tenchucvu.ToString();
        ddr_chucvu.DataValueField = tbchucvuDTOColumn.Machucvu.ToString();
        ddr_chucvu.DataBind();
    }
    protected void btn_Them_Click(object sender, EventArgs e)
    {
        ////try
        //{
            tbnhanvienDTO nv = new tbnhanvienDTO();
            nv.Tennv = txt_tennv.Text;
            nv.Ngaysinh = DatePicker1.SelectedDate;
            nv.Gioitinh = int.Parse(drop_gt.SelectedValue.ToString());
            nv.Taikhoan = txt_taikhoan.Text;
            nv.Matkhau = txt_matkhau.Text;
            nv.Machucvu = int.Parse(ddr_chucvu.SelectedValue.ToString());
            tbnhanvienBUS.Insert(nv);
            Response.Redirect("nhanvienlist.aspx");
        //}
        ////catch
        ////{
        ////    Response.Redirect("nhanvienthem.aspx");
        //}
    }
}
